import { Controller, Post, Body } from '@nestjs/common';
import { MenuService } from './menu.service';
import { CreateMenuDto, FindMenuDto, UpdateMenuDto, RemoveMenuDto, CreateBatchMenuDto, RemoveBatchMenuDto } from './dto/menu.dto';
import { Authority } from '@/common/decorators/authority.decorator';
import { useResult } from '@/common/hooks/useResult';

@Controller('menu')
export class MenuController {
  constructor(private readonly menuService: MenuService) {}

  @Post('create')
  @Authority('menu:create')
  async create(@Body() body: CreateMenuDto) {
    const res = await this.menuService.create(body);
    return useResult(res);
  }

  @Post('findAll')
  @Authority('menu:find')
  async findAll(@Body() body: FindMenuDto) {
    const res = await this.menuService.findAll(body);
    return useResult(res);
  }

  @Post('findOne')
  @Authority('menu:find')
  async findOne(@Body() body: FindMenuDto) {
    const res = await this.menuService.findOne(body);
    return useResult(res);
  }

  @Post('update')
  @Authority('menu:update')
  async update(@Body() body: UpdateMenuDto) {
    const res = await this.menuService.update(body);
    return useResult(res);
  }

  @Post('remove')
  @Authority('menu:remove')
  async remove(@Body() body: RemoveMenuDto) {
    const res = await this.menuService.remove(body);
    return useResult(res);
  }

  @Post('removeBatch')
  @Authority('menu:remove')
  async removeBatch(@Body() body: RemoveBatchMenuDto) {
    const res = await this.menuService.removeBatch(body);
    return useResult(res);
  }

  @Post('createBatch')
  @Authority('menu:create')
  async createBatch(@Body() body: CreateBatchMenuDto) {
    const res = await this.menuService.createBatch(body);
    return useResult(res);
  }
}
